package com.epam.rd.lab.generics.utils;

import java.util.Collection;
import java.util.LinkedList;

public final class ProductsUtil {

	static <T> void copyAll(Collection<? extends T> input, Collection<T> output) {
		if (output == null || input == null) {
			throw new IllegalArgumentException();
		}
		output.addAll(input);
	}

	static <T> void fromArrayToCollection(T[] a, Collection<T> c) {
		if (c == null) {
			throw new IllegalArgumentException();
		}
		for (int i = 0; i < a.length; i++) {
			T object = a[i];
			c.add(object);
		}
	}

	static <T extends Comparable<T>> Collection<T> getBigger(
			Collection<? extends T> input, T example) {
		Collection<T> temp = new LinkedList<T>();
		if (example == null || input == null) {
			throw new IllegalArgumentException();
		}
		for (T elem : input) {
			if (elem.compareTo(example) > 0) {
				temp.add(elem);
			}
		}
		return temp;
	}

}
